import time

from UI_web_wms.szk.config.config import config
from selenium.webdriver.common.by import By


class Page(config):
    # 点击登录
    login_loc = (By.CSS_SELECTOR, '#ttbar-login-2024 > a.link-login')

    def login(self):
        self.click(self.login_loc)

    # 点击搜索框
    ssk_loc = (By.XPATH, '/html/body/div[1]/div[5]/div[1]/div[2]/div[2]/div[2]/input')

    def ssk(self):
        self.click(self.ssk_loc)

    # 输入文本
    wenben_loc = (By.XPATH, '/html/body/div[1]/div[5]/div[1]/div[2]/div[2]/div[2]/input')

    def wenben(self):
        self.send_keys(self.wenben_loc, '智能手机')

    # 点击按钮
    anniu_loc = (By.XPATH, '/html/body/div[1]/div[5]/div[1]/div[2]/div[2]/div[2]/button')

    def anniu(self):
        self.click(self.anniu_loc)

    # 断言智能手机国家补贴
    dy1_loc = (By.XPATH, '/html/body/div[2]/div[1]/div/div/div[2]/div/div[2]/span[1]')

    def dy1(self):
        self.text(self.dy1_loc)

    def luoji_01(self):
        self.open_url('https://www.jd.com/')
        self.login()
        time.sleep(3)
        self.ssk()
        time.sleep(3)
        self.wenben()
        time.sleep(3)
        self.anniu()
        t = time.strftime('%Y%m%d%H%M%S')
        t.swapcase()

        dy11 = self.dy1()
        print(dy11)
        assert '智能手机' in dy11
